package com.platform.service.impl;

import com.platform.cache.J2CacheUtils;
import com.platform.dao.ProCategoryDao;
import com.platform.entity.ProCategoryEntity;
import com.platform.service.ProCategoryService;
import com.platform.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Service实现类
 *  编辑商品:商品类型
 * @author liweihai
 * @email liweihai12345@sina.com
 * @date 2019-03-29 10:09:37
 */
@Service("proCategoryService")
public class ProCategoryServiceImpl implements ProCategoryService {
    @Autowired
    private ProCategoryDao tProCategoryDao;

    @Override
    public ProCategoryEntity queryObject(Integer id) {
        return tProCategoryDao.queryObject(id);
    }

    @Override
    public List<ProCategoryEntity> queryList(Map<String, Object> map) {
        J2CacheUtils.clear(Constants.REDIS_PRO_CATE_KEY);
        return tProCategoryDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        //J2CacheUtils.remove(Constants.REDIS_PRO_CATE_KEY,Constants.REDIS_PRO_CATE_KEY);
        return tProCategoryDao.queryTotal(map);
    }

    @Override
    public int save(ProCategoryEntity tProCategory) {
        System.out.println("save");
        J2CacheUtils.clear(Constants.REDIS_PRO_CATE_KEY);
        return tProCategoryDao.save(tProCategory);
    }

    @Override
    public int update(ProCategoryEntity tProCategory) {
        System.out.println("update");
        J2CacheUtils.clear(Constants.REDIS_PRO_CATE_KEY);
        return tProCategoryDao.update(tProCategory);
    }

    @Override
    public int delete(Integer id) {
        System.out.println("delete");
        J2CacheUtils.clear(Constants.REDIS_PRO_CATE_KEY);
        return tProCategoryDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        System.out.println("deleteBatch");
        J2CacheUtils.clear(Constants.REDIS_PRO_CATE_KEY);
        tProCategoryDao.deleteByParentBatch(ids);
        return tProCategoryDao.deleteBatch(ids);
    }
}
